package com.example.soapserver.endpoint;

import com.example.soapserver.model.user.*;
import com.example.soapserver.service.UserWebService;
import com.example.soapserver.service.impl.UserWebServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class UserServiceEndpoint {
    
    private static final String NAMESPACE_URI = "http://com.cssc.cn/webservice/user";

    @Autowired
    private final UserWebServiceImpl userService;
    
    public UserServiceEndpoint(UserWebServiceImpl userService) {
        this.userService = userService;
    }
    
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "receiveUserDataRequest")
    @ResponsePayload
    public ReceiveUserDataResponse receiveUserData(@RequestPayload ReceiveUserDataRequest request) {
        return userService.receiveUserData(request);
    }
    
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getUserRequest")
    @ResponsePayload
    public GetUserResponse getUser(@RequestPayload GetUserRequest request) {
        return userService.getUser(request);
    }
    
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "userLoginRequest")
    @ResponsePayload
    public UserLoginResponse userLogin(@RequestPayload UserLoginRequest request) {
        return userService.userLogin(request);
    }
    
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "updatePasswordRequest")
    @ResponsePayload
    public UpdatePasswordResponse updatePassword(@RequestPayload UpdatePasswordRequest request) {
        return userService.updatePassword(request);
    }
    
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "getUsersByDeptRequest")
    @ResponsePayload
    public GetUsersByDeptResponse getUsersByDept(@RequestPayload GetUsersByDeptRequest request) {
        return userService.getUsersByDept(request);
    }
}